// 1. 加载React模块
import React, {Component} from 'react';
//import type {Node} from 'react';
import AppNavigator from './src/navigator/AppNavigator.js'
//<Provider>组件：这个组件需要包裹在整个组件树的最外层。这个组件让跟组件的所有子孙组件能够轻松的使用connect()方法绑定store
// connect()：这是react-redux提供的一个方法，如果一个组件想要响应状态的变化，就把自己作为参数传给connect()的结果，connect()方法会处理与store绑定的细节，并通过selector确定该绑定store中哪一部分的数据
import {Provider} from 'react-redux'

import store from "./src/store"
import {TouchableOpacity,Text} from "react-native"
//import {   NativeBaseProvider } from "native-base";
import { RootSiblingPortal, setSiblingWrapper  } from 'react-native-root-siblings';
//在RootSiblings中使用redux上下文之前调用setSiblingWrapper
setSiblingWrapper((sibling) => <Provider store={store}>{sibling}</Provider>);
// 2. 加载原生组件
import {
  SafeAreaView,
  ScrollView,
  StatusBar,
  StyleSheet,
  useColorScheme,
  View,
} from 'react-native';

import {
  Colors,
  DebugInstructions,
  Header,
  LearnMoreLinks,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import {getToken} from "./src/utils/Auth";
import {Set_Token} from "./src/store/actions/user";

class App extends Component {
  constructor() {
    super();

  }
  componentDidMount() {
    this.init()
  }
  init = () => {
    //如果本地有数据直接用本地的数据
      getToken().then(res => {
        console.log(res, "如果本地有数据直接用本地的数据")
        let action = Set_Token(res)
        store.dispatch(action)
      })
  }

  render() {
    return (
        <RootSiblingPortal>
          <View style={{flex:10000}}>
            <AppNavigator></AppNavigator>
          </View>
        </RootSiblingPortal>



    );
  }
}

// 4. 创建样式对象
// 传入样式对象，根据样式中的对象描述，创建样式表
const styles = StyleSheet.create({
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
  },
  highlight: {
    fontWeight: '700',
  },
});
// 5. 导出当前模块
export default App;
